var showData = [{
    id:"ZZZZ",
    text: "全国"
}];

/**
 * 获取省份地市的待选数据
 * @returns {[*]}
 */
function initProvinceAndCityDataTree(weigetId) {

    $.ajax({
        url : WEB_ROOT+"/basicdatabeg/getprovinceareaselectdatatree",
        data : {},
        async : true,
        type : "POST",
        dataType : "json",
        success: function (data) {
            if (data.success) {
                showData[0].nodes =data.treeViewVOList ;
                initTreeViewById(weigetId,showData);
            } else{

            }
        }
    });
    return showData;
}

/**
 * 查询参数初始化获取省份地市的待选数据，增加一个全部查询的选项
 * @returns {[*]}
 */
function initAreaDataTreeBySearch(weigetId) {

    $.ajax({
        url : WEB_ROOT+"/basicdatabeg/getprovinceareaselectdatatree",
        data : {},
        async : true,
        type : "POST",
        dataType : "json",
        success: function (data) {
            if (data.success) {
                showData[0].nodes =data.treeViewVOList ;
                initTreeViewByUseRange(weigetId,showData);
            } else{

            }
        }
    });
    return showData;
}

/**
 * 获取省份的待选数据（多选）
 * @returns {[*]}
 */
function getAllProvinceDataTree(weigetId) {
	showData[0].nodes = provinceCommonData ;
    initTreeViewById(weigetId,showData);
    return showData;
}


/**
 * 获取省份的待选数据（单选）
 * @returns {[*]}
 */
function initAllProvinceDataTreeByDanXuan(weigetId) {

    $.ajax({
        url : WEB_ROOT+"/basicdatabeg/getallprovincedatatree",
        data : {},
        async : true,
        type : "POST",
        dataType : "json",
        success: function (data) {
            if (data.success) {
                showData[0].nodes =data.treeViewVOList ;
                initTreeViewByUseRange(weigetId,showData,false);
            } else{

            }
        }
    });
    return showData;
}



/**
 *使用范围的省份树形菜单初始化
 * @param widgetId
 * @param treeData
 * @param showlevels
 */
function initTreeViewByUseRange(widgetId,treeData,isDuoXuan){
    var treeShowlevels = 2;
    var control  = $('#' + widgetId);
    control.treeview({
        data: treeData,
        silent: true ,
        highlightSelected: true,    //是否高亮选中
        levels: treeShowlevels,   //展示层级控制
        multiSelect: isDuoXuan,  //多选
        onNodeSelected: function(event, node) { //选中节点
            var selectNodes = getChildNodeIdArr(node); //获取所有子节点
            if(node.state.expanded){
                //处于展开状态则折叠
                //control.treeview('collapseNode', node.nodeId);
            } else {
                //展开
                control.treeview('expandNode', node.nodeId);
            }
        },
        onNodeUnselected: function(event, node) {
        },
        onNodeExpanded:
            function(event, data) {
            }
    });
}

    /**
 * 获取券的分类
 * @param nodeId
 * @returns {Array}
 */
function getClassifyDataTreeByCoupon(nodeId) {
    var param = {};
    param.catType ="1" ; //0:卡 1:券
    param.parentId = nodeId;
    var dataList = new Array;
    $.ajax({
        url : WEB_ROOT+"/commondatabeg/getclassifywaitselectdatatree",
        data : param,
        async : false,
        type : "POST",
        dataType : "json",
        success: function (data) {
            if (data.success) {
                dataList = data.treeViewVOList ;
            }
        }
    });
    return dataList;
}

/**
 * 获取卡的分类
 * @param nodeId
 * @returns {Array}
 */
function getClassifyDataTreeByCard(nodeId) {
    var param = {};
    param.catType ="0" ; //0:卡 1:券
    param.parentId = nodeId;
    var dataList = new Array;
    $.ajax({
        url : WEB_ROOT+"/commondatabeg/getclassifywaitselectdatatree",
        data : param,
        async : false,
        type : "POST",
        dataType : "json",
        success: function (data) {
            if (data.success) {
                dataList = data.treeViewVOList ;
            }
        }
    });
    return dataList;
}

/**
 * 获取菜单的分类
 *
 */
function getMenuDataTree(parentMenuCode) {
    var param = {};
    param.parentMenuCode = parentMenuCode;
    var dataList = new Array;
    $.ajax({
        url : WEB_ROOT+"/commondatabeg/getMenuDataTree",
        data : param,
        async : false,
        type : "POST",
        dataType : "json",
        success: function (data) {
            if (data.success) {
                dataList = data.treeViewVOList ;
            }
        }
    });
    return dataList;
}